#ifndef NR_DEVICE_TYPE_H
#define NR_DEVICE_TYPE_H

#include "nr_device_type_property.h"

class nr_device;

typedef nr_error_t (*nr_create_device_fun)(nr_id_t device_type_id, void **p_device);
typedef nr_error_t (*nr_free_device_fun)(void *device);

typedef QSet<nr_id_t> nr_device_type_id_set;

class nr_device_type : public nr_object
{
public:
    nr_device_type();
    ~nr_device_type();
    
    nr_id_t& id() { return m_id; }
    QString& name() { return m_name; }
    QString& text() { return m_text; }
    QString& category() { return m_category; }
    QString& description() { return m_description; }
    QString& module() { return m_module; }

    nr_device_type_properties& properties() { return m_properties; }
    nr_device_type_parameters& parameters() { return m_parameters; }
    nr_device_type_events& events() { return m_events; }
    nr_device_type_id_set& child_types() { return m_child_types; }
    
    nr_error_t load_module();
    nr_device* create_device();
    void destroy_device(nr_device* device);

private:
    nr_id_t m_id;
    QString m_name, m_text, m_category, m_description, m_module;
    nr_device_type_properties m_properties;
    nr_device_type_parameters m_parameters;
    nr_device_type_events m_events;
    nr_device_type_id_set m_child_types;

    nr_create_device_fun m_create_device_fun;
    nr_free_device_fun m_free_device_fun;
};

typedef QHash<nr_id_t, nr_device_type*>  nr_device_types;

#endif // NR_DEVICE_TYPE_H
